<template>
	<view class="container"> 
		<view class="text">
			<u--textarea v-model="value" placeholder="请输入内容" count ></u--textarea>
		</view>
		
		<button @click="sub">发表</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value:'',
				
			}
		},
		mounted() {
			console.log(this.$store.state.users._id)
		},
		methods: {
			sub(){
				if(this.value==''){
					uni.showToast({
						title:'内容不能为空~'
					})
					return false
				}
				uniCloud.callFunction({
					name:'add_shuoshuo',
					data:{
						content:this.value,
						user_id:this.$store.state.users._id
					}
				}).then(res=>{
					console.log(res)
					if(res.errCode==0){
						uni.showToast({
							title:'提交成功~',
							icon:'none',
							success() {
								setTimeout(()=>{
									uni.switchTab({
										url: '/pages/my_tools/my_tools'
									})
								},1000)
								
							}
						})
						
					}
				})
			}
		}
	}
</script>

<style scoped>
	.container{
		padding: 25rpx;
		box-sizing: border-box;
		height: calc(100vh - 100rpx);
	/* 	display: flex;
		flex-direction: column;
		justify-content:space-between; */
	}

	button {
		width: 80%;
		height: 70rpx;
		line-height: 70rpx;
		font-size: 34rpx;
		background: #006594;
		color: #fff;
		margin-top: 50px;
	}
</style>
